#pragma once
#include "Window/IMsgFilter.h"
#include "Window/Wnd.h"
#include "event/event_dispatcher.h"


class CxTray
    : public IMsgFilter
    , public CxEventDispatcher
{
public:
    CxTray(UINT uTrayIconId);
    ~CxTray();

    enum xTray_Event_Id
    {
        xTray_Event_Config  = 1,
        xTray_Event_Exit    = 2,
    };

    BOOL SetTooltip(const std::wstring& strTips);

    virtual LRESULT process(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LPBOOL pbHandled);

private:
    void    _build_wnd();
    void    _rebuild_tray();
    bool    _add_tray_icon();
    bool    _delete_tray_icon();
    void    _init_icon_data(NOTIFYICONDATA* icon_data);
    void    _track_pop_menu(const POINT& pt);


private:
    CxWnd           m_oWnd;
    UINT            m_uTrayIconId;
    NOTIFYICONDATA  m_oIconData;

    HMENU           m_hMenu;

    static UINT     kTaskbarCreated;
};